//
//  BaseViewController.swift
//  weibo
//
//  Created by 胡海波 on 15/6/25.
//  Copyright © 2015年 胡海波. All rights reserved.
//

import UIKit

class BaseViewController: UITableViewController ,VistorLoginViewDelegate{


    /// 用户登录标记
    var userLogin = sharedUserAccount != nil

    // 定义全局变量 -- 访客视图
    var vistorView: VistorLoginView?


    override func loadView() {


        print("用户登录 \(userLogin)")

        userLogin ? super.loadView() : setupVistorView()
    }

    private func setupVistorView() {

        vistorView = VistorLoginView()
        view = vistorView

        vistorView?.delegate = self

        // 创建导航栏按钮
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorRegisterButtonClicked")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginButtonClicked")

        
    }


    func visitorRegisterButtonClicked() {

        print("注册")
    }

    func visitorLoginButtonClicked() {

        let vc = OAuthViewController()

        let nav = UINavigationController(rootViewController: vc)

        presentViewController(nav, animated: true,completion: nil)
    }

}
